package com.internetCafes.spms;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;
import javax.servlet.MultipartConfigElement;
import java.util.TimeZone;

@ServletComponentScan
@SpringBootApplication
public class ApplicationBootstrap implements ApplicationContextAware {


    @PostConstruct
    void started() {
        //TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
    }


    public static void main(String[] args) {
		SpringApplication.run(ApplicationBootstrap.class, args);
	}

	private static ApplicationContext applicationContext = null;

	public void setApplicationContext(ApplicationContext applicationContext){
		this.applicationContext = applicationContext;
	}

	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		factory.setMaxFileSize(500 * 1024L * 1024L);
		factory.setMaxRequestSize(500 * 1024L * 1024L);
		return factory.createMultipartConfig();
	}
}

